package com.itheima.mycollection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo2 {
    public static void main(String[] args) {
        // 基于接口多态创建Collection集合容器
        Collection<String> collection = new ArrayList<String>();

        // 往集合中添加元素
        collection.add("仓井红");
        collection.add("仓井绿");
        collection.add("仓井蓝");

        //获取集合的迭代器对象
        Iterator<String> iterator = collection.iterator();

        // 通过it完成集合遍历
        while (iterator.hasNext()){
            String name = iterator.next();
            System.out.println("name = " + name);
        }
    }
}
